#include "ctrldialog.h"
#include "ui_ctrldialog.h"

#define HEARD_HELLO      "Heard-Hello"
#define NEED_PLAY_SWING  "Need-Play-Swing"
#define MONITOR_RESPONSE "Monitor-Response"
#define SEE_LAUGH        "See-Laugh"
#define SEE_SILENCE      "See-Silence"
#define CHILD_RESPOND    "Child-Respond"
#define IDLE             "Idle"
#define GOT_CLOSE        "Got-Close"

ctrlDialog::ctrlDialog(CEbnWorldStateManager * manager, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ctrlDialog)
{
    ui->setupUi(this);
    mpManager = manager;

    connect(ui->helloBtn, SIGNAL(clicked()), this, SLOT(sayHello()));
    connect(ui->smileBtn, SIGNAL(clicked()), this, SLOT(smile()));
    connect(ui->silenceBtn, SIGNAL(clicked()), this, SLOT(silence()));
    connect(ui->encourageBtn, SIGNAL(clicked()), this, SLOT(encourage()));

}

ctrlDialog::~ctrlDialog()
{
    disconnect(ui->helloBtn, SIGNAL(clicked()), this, SLOT(sayHello()));
    disconnect(ui->smileBtn, SIGNAL(clicked()), this, SLOT(smile()));
    disconnect(ui->silenceBtn, SIGNAL(clicked()), this, SLOT(silence()));
    disconnect(ui->encourageBtn, SIGNAL(clicked()), this, SLOT(encourage()));

    mpManager = NULL;
    delete ui;
}

void ctrlDialog::sayHello(void)
{
    if (mpManager)
    {
        mpManager->setWorldStateValue(HEARD_HELLO, 1);
    }
}

void ctrlDialog::smile(void)
{
    if (mpManager)
    {
        mpManager->setWorldStateValue(SEE_LAUGH, 1);
    }
}

void ctrlDialog::silence(void)
{
    if (mpManager)
    {
        mpManager->setWorldStateValue(SEE_SILENCE, 1);
    }
}

void ctrlDialog::encourage(void)
{
    if (mpManager)
    {
        mpManager->setWorldStateValue(CHILD_RESPOND, 1);
    }
}
